﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Shapes;

namespace DragDropExample
{
  public partial class DraggedOverExample : UserControl
  {
    public DraggedOverExample()
    {
      InitializeComponent();
    }

    private void DropTarget_OnDropped(object sender, SilverlightDragDrop.DragDropEventArgs e)
    {
      var sourcetext = ((e.Source as Border).Child as TextBlock).Text;
      
      var target = (sender as SilverlightDragDrop.DropTarget).Content as Border;
      target.Background = new SolidColorBrush(Color.FromArgb(255, 255, 255, 255));

      var targettext = (target.Child as TextBlock).Text;
      Message.Text = String.Format("You dropped '{0}' on '{1}'", sourcetext, targettext);
    }

    private void DropTarget_OnDraggedOver(object sender, SilverlightDragDrop.DragDropEventArgs e)
    {
      var target = (sender as SilverlightDragDrop.DropTarget).Content as Border;
      target.Background = new SolidColorBrush(Color.FromArgb(255, 80, 80, 255));
    }

    private void DropTarget_OnDraggedOut(object sender, SilverlightDragDrop.DragDropEventArgs e)
    {
      var target = (sender as SilverlightDragDrop.DropTarget).Content as Border;
      target.Background = new SolidColorBrush(Color.FromArgb(255, 255, 255, 255));
    }
  }
}
